package com.xtjc03.serial.codec;

import org.apache.mina.core.session.IoSession;
import org.apache.mina.filter.codec.ProtocolCodecFactory;
import org.apache.mina.filter.codec.ProtocolDecoder;
import org.apache.mina.filter.codec.ProtocolEncoder;
import org.springframework.stereotype.Component;

@Component
public class ComMsgProtocolFactory implements ProtocolCodecFactory {

    private ProtocolDecoder protocolDecoder;
    private ProtocolEncoder protocolEncoder;

    public ComMsgProtocolFactory(){
        this.protocolDecoder = new ComMsgDecoder();
        this.protocolEncoder = new ComMsgEncoder();
    }

    @Override
    public ProtocolEncoder getEncoder(IoSession ioSession) throws Exception {
        return this.protocolEncoder;
    }

    @Override
    public ProtocolDecoder getDecoder(IoSession ioSession) throws Exception {
        return this.protocolDecoder;
    }

}
